<?php
return [
    'module' => [
        'name' => 'admin_operation_log',
        'title' => '操作日志',
        'table' => 'admin_operation_logs',
    ],
    
    'fields' => [
        'id' => [
            'type' => 'int',
            'length' => 11,
            'comment' => '日志ID',
            'primary' => true,
            'auto_increment' => true,
            'nullable' => false,
            'required' => true,
        ],
        'admin_id' => [
            'type' => 'int',
            'length' => 11,
            'comment' => '管理员ID',
            'required' => true,
            'nullable' => false,
        ],
        'module' => [
            'type' => 'varchar',
            'length' => 50,
            'comment' => '操作模块',
            'required' => true,
            'nullable' => false,
        ],
        'action' => [
            'type' => 'varchar',
            'length' => 50,
            'comment' => '操作方法',
            'required' => true,
            'nullable' => false,
        ],
        'method' => [
            'type' => 'varchar',
            'length' => 10,
            'comment' => '请求方法',
            'required' => true,
            'nullable' => false,
        ],
        'url' => [
            'type' => 'varchar',
            'length' => 255,
            'comment' => '请求URL',
            'required' => true,
            'nullable' => false,
        ],
        'params' => [
            'type' => 'json',
            'comment' => '请求参数',
            'required' => false,
            'nullable' => true,
        ],
        'ip' => [
            'type' => 'varchar',
            'length' => 45,
            'comment' => '操作IP',
            'required' => true,
            'nullable' => false,
        ],
        'user_agent' => [
            'type' => 'varchar',
            'length' => 255,
            'comment' => '浏览器信息',
            'required' => false,
            'nullable' => true,
        ],
        'description' => [
            'type' => 'varchar',
            'length' => 255,
            'comment' => '操作描述',
            'required' => false,
            'nullable' => true,
        ],
        'status' => [
            'type' => 'tinyint',
            'length' => 1,
            'comment' => '操作状态',
            'default' => 1,
            'options' => [
                0 => '失败',
                1 => '成功'
            ],
        ],
        'created_at' => [
            'type' => 'timestamp',
            'comment' => '创建时间',
            'nullable' => false,
            'default' => 'CURRENT_TIMESTAMP',
            'raw_default' => true
        ],
    ],
    
    'relations' => [
        'admin' => [
            'type' => 'belongsTo',
            'model' => 'Admin',
            'foreign_key' => 'admin_id',
        ],
    ],
    
    'queries' => [
        'admin_id' => ['=', '?'],
        'module' => ['like', '%?%'],
        'action' => ['like', '%?%'],
        'method' => ['=', '?'],
        'ip' => ['like', '%?%'],
        'status' => ['=', '?'],
        'created_at' => ['between', '?,?'],
    ],
]; 